home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / WNDLIB10.ZIP;1 / WNDCLASS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-25  |  55.5 KB  |  1,650 lines

  1. /* WNDCLASS.H v1.0 Copyright (c) 1993, 1994 Burnham Park Software, Inc. */
  2. #ifndef __WNDCLASS_H
  3. #define __WNDCLASS_H
  4.  
  5. #ifndef __WINDOWS_H
  6. #include <windows.h>
  7. #endif
  8.  
  9. #ifndef __MEM_H
  10. #include <mem.h>
  11. #endif
  12.  
  13. #define CW_FIRSTCHILD 500
  14.  
  15. #define DBFUNC BOOL FAR PASCAL _export
  16. #define WNDPROC long FAR PASCAL _export
  17.  
  18. #define BLACK RGB(0, 0, 0)
  19. #define DARKBLUE RGB(0, 0, 128)
  20. #define DARKGREEN RGB(0, 128, 0)
  21. #define DARKCYAN RGB(0, 128, 128)
  22. #define DARKRED RGB(128, 0, 0)
  23. #define DARKMAGENTA RGB(128, 0, 128)
  24. #define DARKYELLOW RGB(128, 128, 0)
  25. #define DARKGREY RGB(128, 128, 128)
  26. #define GREY RGB(192, 192, 192)
  27. #define BLUE RGB(0, 0, 255)
  28. #define GREEN RGB(0, 255, 0)
  29. #define CYAN RGB(0, 255, 255)
  30. #define RED RGB(255, 0, 0)
  31. #define MAGENTA RGB(255, 0, 255)
  32. #define YELLOW RGB(255, 255, 0)
  33. #define WHITE RGB(255, 255, 255)
  34.  
  35. #define wabs(a) (((a) >= 0) ? (a) : (0 - (a)))
  36. #define wmax(a, b) (((a) > (b)) ? (a) : (b))
  37. #define wmin(a, b) (((a) < (b)) ? (a) : (b))
  38. #define wdir(a, b) (((a) == (b)) ? 0 : (((b) > (a)) ? 1 : -1))
  39.  
  40. typedef LONG (FAR PASCAL *LPFN)(HWND, unsigned int, unsigned int, LONG);
  41.  
  42. class BASEWINDOW_CLASS{
  43.   protected:
  44.     HWND hwnd;
  45.   public:
  46.     HWND Get() { return hwnd; }
  47.     void Set(HWND wnd) { hwnd = wnd; }
  48.     BOOL Show(int input) { return ShowWindow(hwnd, input); }
  49.     BOOL Show() { return Show(SW_SHOWNORMAL); }
  50.     BOOL ShowMaximized() { return Show(SW_SHOWMAXIMIZED); }
  51.     void Update() { UpdateWindow(hwnd); }
  52.     LONG SendMessage(UINT message, WPARAM wparam, LPARAM lparam)
  53.      { return ::SendMessage(hwnd, message, wparam, lparam); }
  54.     LONG SendMessage(UINT message, WPARAM wparam)
  55.      { return SendMessage(message, wparam, 0L); }
  56.     LONG SendMessage(UINT message) { return SendMessage(message, 0); }
  57.     void SendCommand(WPARAM wparam, LPARAM lparam)
  58.      { ::SendMessage(hwnd, WM_COMMAND, wparam, lparam); }
  59.     void SendCommand(WPARAM wparam) { SendCommand(wparam, 0L); }
  60.     void PostMessage(UINT message, WPARAM wparam, LPARAM lparam)
  61.      { ::PostMessage(hwnd, message, wparam, lparam); }
  62.     void PostMessage(UINT message, WPARAM wparam)
  63.      { PostMessage(message, wparam, 0L); }
  64.     void PostMessage(UINT message) { PostMessage(message, 0); }
  65.     void PostCommand(WPARAM wparam, LPARAM lparam)
  66.      { ::PostMessage(hwnd, WM_COMMAND, wparam, lparam); }
  67.     void PostCommand(WPARAM wparam) { PostCommand(wparam, 0L); }
  68.     void GetWindowText(LPSTR string, int length)
  69.      { ::GetWindowText(hwnd, string, length); }
  70.     void SetWindowText(LPSTR string)
  71.      { ::SetWindowText(hwnd, string); }
  72.     void Invalidate(const RECT FAR *rect, BOOL erase)
  73.      { InvalidateRect(hwnd, rect, erase); }
  74.     void Invalidate(BOOL erase) { Invalidate(NULL, erase); }
  75.     void Invalidate() { Invalidate(NULL, FALSE); }
  76.     void GetRect(RECT FAR *rect) { GetWindowRect(hwnd, rect); }
  77.     void GetClientRect(RECT FAR *rect) { ::GetClientRect(hwnd, rect); }
  78. };
  79.  
  80. class WINDOW_CLASS : public BASEWINDOW_CLASS{
  81.   protected:
  82.     struct{
  83.       LPSTR lpClassName, lpWindowName, lpParam;
  84.       DWORD dwStyle;
  85.       int X, Y, nWidth, nHeight;
  86.       HWND hWndParent;
  87.       HMENU hMenu;
  88.       HANDLE hInstance;
  89.     } wnd;
  90.   public:
  91.     WINDOW_CLASS(HANDLE input1, LPSTR input2){
  92.       wnd.lpClassName = input2;
  93.       wnd.lpWindowName = NULL;
  94.       wnd.dwStyle = WS_OVERLAPPEDWINDOW;
  95.       wnd.X = CW_USEDEFAULT;
  96.       wnd.Y = CW_USEDEFAULT;
  97.       wnd.nWidth = CW_USEDEFAULT;
  98.       wnd.nHeight = CW_USEDEFAULT;
  99.       wnd.hWndParent = NULL;
  100.       wnd.hMenu = NULL;
  101.       wnd.hInstance = input1;
  102.       wnd.lpParam = NULL;
  103.     }
  104.     void Create() { hwnd = CreateWindow(wnd.lpClassName, wnd.lpWindowName,
  105.      wnd.dwStyle, wnd.X, wnd.Y, wnd.nWidth, wnd.nHeight, wnd.hWndParent,
  106.      wnd.hMenu, wnd.hInstance, wnd.lpParam); }
  107.     void Display(int input){
  108.       Create();
  109.       Show(input);
  110.       Update();
  111.     }
  112.     void Display() { Display(SW_SHOWNORMAL); }
  113.     void DisplayMaximized() { Display(SW_SHOWMAXIMIZED); }
  114.     void lpClassName(LPSTR input) { wnd.lpClassName = input; }
  115.     void lpWindowName(LPSTR input) { wnd.lpWindowName = input; }
  116.     void dwStyle(DWORD input) { wnd.dwStyle = input; }
  117.     void X(int input) { wnd.X = input; }
  118.     void Y(int input) { wnd.Y = input; }
  119.     void nWidth(int input) { wnd.nWidth = input; }
  120.     void nHeight(int input) { wnd.nHeight = input; }
  121.     void hWndParent(HWND input) { wnd.hWndParent = input; }
  122.     void hMenu(HMENU input) { wnd.hMenu = input; }
  123.     virtual void hInstance(HANDLE input) { wnd.hInstance = input; }
  124.     void lpParam(LPSTR input) { wnd.lpParam = input; }
  125.     HWND Getchild() { return GetWindow(hwnd, GW_CHILD); }
  126.     HANDLE LoadAccelerators(char* input)
  127.      { return ::LoadAccelerators(wnd.hInstance, input); }
  128.     HANDLE LoadAccelerators()
  129.      { return ::LoadAccelerators(wnd.hInstance, wnd.lpClassName); }
  130. };
  131.  
  132. class WINDOWMESSAGE_CLASS : public WINDOW_CLASS{
  133.   protected:
  134.     MSG msg;
  135.   public:
  136.     WINDOWMESSAGE_CLASS(HANDLE input1, LPSTR input2) : WINDOW_CLASS(input1, input2) { }
  137.     HWND Getmsghwnd() { return msg.hwnd; }
  138.     UINT Getmsgmessage() { return msg.message; }
  139.     WPARAM GetmsgwParam() { return msg.wParam; }
  140.     LPARAM GetmsglParam() { return msg.lParam; }
  141.     int TranslateAccelerator(HANDLE haccel)
  142.      { return ::TranslateAccelerator(hwnd, haccel, &msg); }
  143.     int TranslateMDISysAccel()
  144.      { return ::TranslateMDISysAccel(Getchild(), &msg); }
  145.     int IsDialogMessage(HWND hmodeless)
  146.      { return ::IsDialogMessage(hmodeless, &msg); } 
  147.     int TestMessage() { return GetMessage(&msg, NULL, 0, 0); }
  148.     void DoMessage(){
  149.       TranslateMessage(&msg);
  150.       DispatchMessage(&msg);
  151.     }
  152.     void AccelMessage(HANDLE haccel)
  153.      { if(TranslateAccelerator(haccel) == FALSE) DoMessage(); }
  154.     void ModelessMessage(HWND hmodeless){
  155.       if(hmodeless == NULL || IsDialogMessage(hmodeless) == FALSE)
  156.        DoMessage();
  157.     }
  158.     void ModelessAccelMessage(HWND hmodeless, HANDLE haccel){
  159.       if(hmodeless == NULL || IsDialogMessage(hmodeless) == FALSE)
  160.        AccelMessage(haccel);
  161.     }
  162. };
  163.  
  164. class WINDOWACCEL_CLASS : public WINDOWMESSAGE_CLASS{
  165.   protected:
  166.     HANDLE haccel;
  167.   public:
  168.     WINDOWACCEL_CLASS(HANDLE input1, LPSTR input2) : WINDOWMESSAGE_CLASS(input1, input2) { }
  169.     void LoadAccelerators(char* input)
  170.      { haccel = WINDOW_CLASS::LoadAccelerators(input); }
  171.     void LoadAccelerators()
  172.      { haccel = WINDOW_CLASS::LoadAccelerators(); }
  173.     int TranslateAccelerator()
  174.      { return WINDOWMESSAGE_CLASS::TranslateAccelerator(haccel); }
  175.     void AccelMessage() { WINDOWMESSAGE_CLASS::AccelMessage(haccel); }
  176.     void ModelessAccelMessage(HWND hmodeless){
  177.       if(hmodeless == NULL || IsDialogMessage(hmodeless) == FALSE)
  178.        AccelMessage();
  179.     }
  180. };
  181.  
  182. class EDITWINDOW_CLASS : public virtual WINDOW_CLASS{
  183.   public:
  184.     EDITWINDOW_CLASS(HANDLE input1, HWND input2) : WINDOW_CLASS(input1,
  185.      "edit"){
  186.       wnd.dwStyle = WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
  187.        WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL |
  188.        ES_AUTOVSCROLL;
  189.       wnd.hWndParent = input2;
  190.     }
  191.     EDITWINDOW_CLASS(LONG input1, HWND input2) :
  192.      WINDOW_CLASS(((LPCREATESTRUCT)input1)->hInstance, "edit"){
  193.       wnd.dwStyle = WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
  194.        WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL |
  195.        ES_AUTOVSCROLL;
  196.       wnd.hWndParent = input2;
  197.     }
  198.     void SetFocus() { ::SetFocus(hwnd); }
  199.     void MoveWindow(LONG input)
  200.       { ::MoveWindow(hwnd, 0, 0, LOWORD(input), HIWORD(input), TRUE); }
  201. };
  202.  
  203. class BUTTONWINDOW_CLASS : public virtual WINDOW_CLASS{
  204.   public:
  205.     BUTTONWINDOW_CLASS(HANDLE input1, HWND input2) : WINDOW_CLASS(input1,
  206.      "button"){
  207.       wnd.dwStyle = WS_CHILD | WS_VISIBLE;
  208.       wnd.hWndParent = input2;
  209.     }
  210. };
  211.  
  212. class LISTBOXWINDOW_CLASS : public virtual WINDOW_CLASS{
  213.   public:
  214.     LISTBOXWINDOW_CLASS(HANDLE input1, HWND input2) : WINDOW_CLASS(input1,
  215.      "listbox"){
  216.       wnd.dwStyle = WS_CHILD | WS_VISIBLE | LBS_STANDARD;
  217.       wnd.hWndParent = input2;
  218.     }
  219.     void Reset() { BASEWINDOW_CLASS::SendMessage(LB_RESETCONTENT); }
  220.     int Addstring(LPSTR string)
  221.      { return BASEWINDOW_CLASS::SendMessage(LB_ADDSTRING, 0, (LPARAM)string); }
  222.     int Insertstring(LPSTR string, int index)
  223.      { return BASEWINDOW_CLASS::SendMessage(LB_INSERTSTRING, index, (LPARAM)string); }
  224.     int Deletestring(int index)
  225.      { return BASEWINDOW_CLASS::SendMessage(LB_DELETESTRING, index); }
  226.     void Setredraw(int flag)
  227.      { BASEWINDOW_CLASS::SendMessage(WM_SETREDRAW, flag); }
  228.     void Setredraw() { Setredraw(TRUE); }
  229.     void Resetredraw() { Setredraw(FALSE); }
  230.     LONG Getcount() { return BASEWINDOW_CLASS::SendMessage(LB_GETCOUNT); }
  231.     LONG Getsel() { return BASEWINDOW_CLASS::SendMessage(LB_GETCURSEL); }
  232.     void Setsel(int index) { BASEWINDOW_CLASS::SendMessage(LB_SETCURSEL, index); }
  233.     int Selectstring(LPSTR string, int index)
  234.      { return BASEWINDOW_CLASS::SendMessage(LB_SELECTSTRING, index, (LPARAM)string); }
  235.     int Selectstring(LPSTR string) { return Selectstring(string, -1); }
  236.     int Gettextlen(int index)
  237.      { return BASEWINDOW_CLASS::SendMessage(LB_GETTEXTLEN, index); }
  238.     int Gettext(LPSTR string, int index)
  239.      { return BASEWINDOW_CLASS::SendMessage(LB_GETTEXT, index, (LPARAM)string); }
  240.     void Setmultiplesel(int index, int flag)
  241.      { BASEWINDOW_CLASS::SendMessage(LB_SETSEL, flag, (LPARAM)index); }
  242.     void Setmultiplesel(int index) { Setmultiplesel(index, TRUE); }
  243.     void Resetmultiplesel(int index) { Setmultiplesel(index, FALSE); }
  244.     void Setmultipleall(int flag) { Setmultiplesel(-1, flag); }
  245.     void Setmultipleall() { Setmultipleall(TRUE); }
  246.     void Resetmultipleall() { Setmultipleall(FALSE); }
  247. };
  248.  
  249. class DIALOGBOXWINDOW_CLASS : public virtual BASEWINDOW_CLASS{
  250.   protected:
  251.     BOOL error;
  252.   public:
  253.     DIALOGBOXWINDOW_CLASS(HWND input) { hwnd = input; }
  254.     int Getnoerror() { return error > 0; }
  255.     void CheckButton(int control, int state)
  256.      { CheckDlgButton(hwnd, control, state); }
  257.     void CheckButton(int control)
  258.      { CheckButton(control, TRUE); }
  259.     void UncheckButton(int control)
  260.      { CheckButton(control, FALSE); }
  261.     void GrayButton(int control)
  262.      { CheckButton(control, 2); }
  263.     void CheckRadio(int first, int last, int checked)
  264.      { CheckRadioButton(hwnd, first, last, checked); }
  265.     void CheckRadio(int first, int last)
  266.      { CheckRadio(first, last, first); }
  267.     void End(int value) { ::EndDialog(hwnd, value); }
  268.     void End() { End(FALSE); }
  269.     HWND GetItem(int control) { return GetDlgItem(hwnd, control); }
  270.     int GetInt(int control, int sign)
  271.      { return GetDlgItemInt(hwnd, control, &error, sign); }
  272.     int GetInt(int control) { return GetInt(control, TRUE); }
  273.     void GetText(int control, LPSTR string, int chars)
  274.      { GetDlgItemText(hwnd, control, string, chars); }
  275.     void GetText(int control, LPSTR string)
  276.      { GetText(control, string, 255); }
  277.     void SetInt(int control, int value, int sign)
  278.      { SetDlgItemInt(hwnd, control, value, sign); }
  279.     void SetInt(int control, int value)
  280.      { SetInt(control, value, FALSE); }
  281.     void SetText(int control, LPSTR string)
  282.      { SetDlgItemText(hwnd, control, string); }
  283.     int IsButtonChecked(int control)
  284.      { return IsDlgButtonChecked(hwnd, control); }
  285.     void HideItem(int control) { ShowWindow(GetItem(control), SW_HIDE); }
  286.     void ShowItem(int control) { ShowWindow(GetItem(control), SW_SHOW); }
  287.     void EnableItem(int control, int flag) { EnableWindow(GetItem(control), flag); }
  288.     void EnableItem(int control) { EnableItem(control, TRUE); }
  289.     void DisableItem(int control) { EnableItem(control, FALSE); }
  290.     void EnableOK(int flag) { EnableItem(IDOK, flag); }
  291.     void EnableOK() { EnableOK(TRUE); }
  292.     void DisableOK() { EnableOK(FALSE); }
  293.     LONG SendItemMessage(int control, UINT message, WPARAM wparam, LPARAM lparam)
  294.      { return SendDlgItemMessage(hwnd, control, message, wparam, lparam); }
  295.     LONG SendItemMessage(int control, UINT message, WPARAM wparam)
  296.      { return SendItemMessage(control, message, wparam, 0L); }
  297.     LONG SendItemMessage(int control, UINT message)
  298.      { return SendItemMessage(control, message, 0, 0L); }
  299.     void LimitText(int control, int length)
  300.      { SendItemMessage(control, EM_LIMITTEXT, length); }
  301.     void SetLimitText(int control, LPSTR string, int length){
  302.       LimitText(control, length);
  303.       SetText(control, string);
  304.     }
  305.     void SetLimitInt(int control, int value, int length){
  306.       LimitText(control, length);
  307.       SetInt(control, value);
  308.     }
  309.     void SetScrollRange(int control, int range)
  310.      { ::SetScrollRange(GetDlgItem(hwnd, control), SB_CTL, 0, range - 1, FALSE); }
  311.     void SetScrollPos(int control, int position)
  312.      { ::SetScrollPos(GetDlgItem(hwnd, control), SB_CTL, position, TRUE); }
  313.     void ListboxReset(int control)
  314.      { SendItemMessage(control, LB_RESETCONTENT); }
  315.     int ListboxAdd(int control, LPSTR string)
  316.      { return SendItemMessage(control, LB_ADDSTRING, 0, (LPARAM)string); }
  317.     int ListboxInsert(int control, int index, LPSTR string)
  318.      { return SendItemMessage(control, LB_INSERTSTRING, index, (LPARAM)string); }
  319.     int ListboxInsert(int control, LPSTR string)
  320.      { return SendItemMessage(control, LB_INSERTSTRING, -1, (LPARAM)string); }
  321.     int ListboxGetcount(int control)
  322.      { return SendItemMessage(control, LB_GETCOUNT); }
  323.     int ListboxGetsel(int control)
  324.      { return SendItemMessage(control, LB_GETCURSEL); }
  325.     int ListboxGetdata(int control, int index)
  326.      { return SendItemMessage(control, LB_GETITEMDATA, index); }
  327.     void ListboxGettext(int control, int index, LPSTR string)
  328.      { string[SendItemMessage(control, LB_GETTEXT, index, (LPARAM)string)] = 0; }
  329.     void ListboxSetsel(int control, int selection)
  330.      { SendItemMessage(control, LB_SETCURSEL, selection); }
  331.     void ListboxSetdata(int control, int index, long data)
  332.      { SendItemMessage(control, LB_SETITEMDATA, data); }
  333.     void ListboxSettabstops(int control, int tabs, int *stops)
  334.      { SendItemMessage(control, LB_SETTABSTOPS, tabs, (LPARAM)(int far*)stops); }
  335.     void ListboxSettabstop(int control, int tab)
  336.      { ListboxSettabstops(control, 1, &tab); }
  337.     void ListboxDelete(int control, int index)
  338.      { SendItemMessage(control, LB_DELETESTRING, index); }
  339.     BOOL FileList(int control, int text, char *filespec)
  340.      { return DlgDirList(hwnd, filespec, control, text, 0); }
  341.     BOOL FileList(int control, char *filespec)
  342.      { return FileList(control, 0, filespec); }
  343.     BOOL FileList(int control)
  344.      { return FileList(control, "*.*"); }
  345.     BOOL DirectoryList(int control, int text, char *filespec)
  346.      { return DlgDirList(hwnd, filespec, control, text, 0x0c010); }
  347.     BOOL DirectoryList(int control, char *filespec)
  348.      { return DirectoryList(control, 0, filespec); }
  349.     BOOL DirectoryList(int control)
  350.      { return DirectoryList(control, "*.*"); }
  351.     BOOL DirectorySelect(int control, char *filespec)
  352.      { return DlgDirSelect(hwnd, filespec, control); }
  353. };
  354.  
  355. class MDICLIENTWINDOW_CLASS : public virtual BASEWINDOW_CLASS{
  356.   protected:
  357.     CLIENTCREATESTRUCT clientcreate;
  358.     DWORD dwstyle;
  359.     HWND hwndParent;
  360.     HANDLE hinstance;
  361.   public:
  362.     MDICLIENTWINDOW_CLASS(HANDLE input1, HWND input2, int input3){
  363.       hwndParent = input2;
  364.       hinstance = input1;
  365.       dwstyle = WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE;
  366.       clientcreate.idFirstChild = CW_FIRSTCHILD;
  367.       clientcreate.hWindowMenu = GetSubMenu(input2, input3);
  368.     }
  369.     void Create(){
  370.       hwnd = CreateWindow("MDICLIENT", NULL, dwstyle, 0, 0, 0, 0, hwndParent,
  371.        1, hinstance, (LPSTR)&clientcreate);
  372.     }
  373.     void Cascade() { SendMessage(WM_MDICASCADE); }
  374.     void Tile() { SendMessage(WM_MDITILE); }
  375.     void Arrange() { SendMessage(WM_MDIICONARRANGE); }
  376.     HWND Gethwnd() { return hwnd; }
  377. };
  378.  
  379. class MDICHILDWINDOW_CLASS : public virtual BASEWINDOW_CLASS{
  380.   protected:
  381.     MDICREATESTRUCT mdicreate;
  382.   public:
  383.     MDICHILDWINDOW_CLASS(HANDLE input1, LPSTR input2, LPSTR input3){
  384.       mdicreate.szClass = input2;
  385.       mdicreate.szTitle = input3;
  386.       mdicreate.hOwner = input1;
  387.       mdicreate.x = CW_USEDEFAULT;
  388.       mdicreate.y = CW_USEDEFAULT;
  389.       mdicreate.cx = CW_USEDEFAULT;
  390.       mdicreate.cy = CW_USEDEFAULT;
  391.       mdicreate.style = 0;
  392.       mdicreate.lParam = NULL;
  393.     }
  394.     void Create(HWND hwndclient){
  395.       hwnd = ::SendMessage(hwndclient, WM_MDICREATE, 0,
  396.        (LPARAM)(LPMDICREATESTRUCT)&mdicreate);
  397.     }
  398.     HWND Gethwnd() { return hwnd; }
  399. };
  400.  
  401. class MOVEWINDOW_CLASS : public BASEWINDOW_CLASS{
  402.   protected:
  403.     RECT xy, pxy;
  404.     unsigned char flag;
  405.   public:
  406.     MOVEWINDOW_CLASS() { flag = FALSE; }
  407.     int GetLEFT() { return xy.left; }
  408.     int GetTOP() { return xy.top; }
  409.     int GetRIGHT() { return xy.right; }
  410.     int GetBOTTOM() { return xy.bottom; }
  411.     void Start(HWND input){
  412.       hwnd = input;
  413.       if(flag == FALSE){
  414.         GetWindowRect(hwnd, &xy);
  415.     flag = TRUE;
  416.       }
  417.       else MoveWindow(hwnd, xy.left, xy.top, xy.right - xy.left,
  418.        xy.bottom - xy.top, FALSE);
  419.     }
  420.     void Move() { GetWindowRect(hwnd, &xy); }
  421.     void Move(int dx, int dy){
  422.       xy.left += dx;
  423.       xy.right += dx;
  424.       xy.top += dy;
  425.       xy.bottom += dy;
  426.       MoveWindow(hwnd, xy.left, xy.top, xy.right - xy.left,
  427.        xy.bottom - xy.top, FALSE);
  428.     }
  429.     void Center(HWND input){
  430.       GetWindowRect(input, &pxy);
  431.       pxy.left = pxy.left + (pxy.right - pxy.left) / 2 - (xy.right - xy.left) / 2 - xy.left;
  432.       pxy.top = pxy.top + (pxy.bottom - pxy.top) / 2 - (xy.bottom - xy.top) / 2 - xy.top;
  433.       Move(pxy.left, pxy.top);
  434.     }
  435.     void Center() { Center(GetParent(hwnd)); }
  436. };
  437.  
  438. class WND_CLASS{
  439.   protected:
  440.     WNDCLASS wc;
  441.   public:
  442.     WND_CLASS(HANDLE input1, LPSTR input2, LPFN input3){
  443.       wc.style = CS_HREDRAW | CS_VREDRAW;
  444.       wc.lpfnWndProc = input3;
  445.       wc.cbClsExtra = 0;
  446.       wc.cbWndExtra = 0;
  447.       wc.hInstance = input1;
  448.       wc.hIcon = ::LoadIcon(NULL, IDI_APPLICATION);
  449.       wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
  450.       wc.hbrBackground = COLOR_WINDOW + 1;
  451.       wc.lpszMenuName = NULL;
  452.       wc.lpszClassName = input2;
  453.     }
  454.     BOOL Register(HANDLE input){
  455.       if(!input) RegisterClass(&wc);
  456.       return input;
  457.     }
  458.     BOOL Register() { return RegisterClass(&wc); }
  459.     void LoadIcon(LPSTR input)
  460.      { wc.hIcon = ::LoadIcon(wc.hInstance, input); }
  461.     void LoadIcon()
  462.      { wc.hIcon = ::LoadIcon(wc.hInstance, wc.lpszClassName); }
  463.     void LoadCursor(LPSTR input)
  464.       { wc.hCursor = ::LoadCursor(wc.hInstance, input); }
  465.     void LoadCursor()
  466.       { wc.hCursor = ::LoadCursor(wc.hInstance, wc.lpszClassName); }
  467.     void style(WORD input) { wc.style = input; }
  468.     void lpfnWndProc(LPFN input) { wc.lpfnWndProc = input; }
  469.     void cbClsExtra(int input) { wc.cbClsExtra = input; }
  470.     void cbWndExtra(int input) { wc.cbWndExtra = input; }
  471.     virtual void hInstance(HANDLE input) { wc.hInstance = input; }
  472.     void hIcon(HICON input) { wc.hIcon = input; }
  473.     void hCursor(HCURSOR input) { wc.hCursor = input; }
  474.     void hbrBackground(HBRUSH input) { wc.hbrBackground = input; }
  475.     void lpszMenuName(LPSTR input) { wc.lpszMenuName = input; }
  476.     void lpszMenuName() { wc.lpszMenuName = wc.lpszClassName; }
  477.     void lpszClassName(LPSTR input) { wc.lpszClassName = input; }
  478. };
  479.  
  480. class INSTANCE_CLASS{
  481.   protected:
  482.     HANDLE hinstance;
  483.   public:
  484.     INSTANCE_CLASS() { hinstance = NULL; }
  485.     INSTANCE_CLASS(HANDLE input) { hinstance = input; }
  486.     HANDLE Get() { return hinstance; }
  487.     void Set(HANDLE input) { hinstance = input; }
  488.     HBITMAP LoadBitmap(LPSTR bitmap) { return ::LoadBitmap(hinstance, bitmap); }
  489.     HCURSOR LoadCursor(LPSTR cursor) { return ::LoadCursor(hinstance, cursor); }
  490.     HICON LoadIcon(LPSTR icon) { return ::LoadIcon(hinstance, icon); }
  491.     HMENU LoadMenu(LPSTR menu) { return ::LoadMenu(hinstance, menu); }
  492.     HGLOBAL LoadResource(HRSRC resource)
  493.      { return ::LoadResource(hinstance, resource); }
  494. };
  495.  
  496. class LOCALMEMORY_CLASS{
  497.   protected:
  498.     LOCALHANDLE hmem;
  499.     NPSTR p_mem;
  500.     unsigned int num;
  501.   public:
  502.     LOCALMEMORY_CLASS(){
  503.       hmem = NULL;
  504.       p_mem = NULL;
  505.       num = 0;
  506.     }
  507.     int Alloc(int input1, int input2){
  508.       Free();
  509.       num = input2;
  510.       hmem = LocalAlloc(input1, input2);
  511.       return hmem;
  512.     }
  513.     int Alloc(int input) { return Alloc(LHND, input); }
  514.     int Allocchar(int input) { return Alloc(LHND, input); }
  515.     int Allocint(int input)
  516.      { return Alloc(input * sizeof(int)); }
  517.     int Allocfloat(int input) { return Alloc(input * sizeof(float)); }
  518.     void Lock() { if(hmem) p_mem = LocalLock(hmem); }
  519.     void Unlock() { if(hmem) LocalUnlock(hmem); }
  520.     void Free(){
  521.       if(hmem){
  522.     LocalFree(hmem);
  523.     hmem = NULL;
  524.       }
  525.       p_mem = NULL;
  526.       num = 0;
  527.     }
  528.     LOCALHANDLE Gethmem() { return hmem; }
  529.     void Sethmem(LOCALHANDLE input) { hmem = input; }
  530.     int Getlen() { return num; }
  531.     int Getlenchar() { return num; }
  532.     int Getlenint() { return num / sizeof(int); }
  533.     int Getlenfloat() { return num / sizeof(float); }
  534.     char Getchar(int input) { return *(p_mem + input); }
  535.     int Getint(int input) { return *((int far*)p_mem + input); }
  536.     float Getfloat(int input) { return *((float far*)p_mem + input); }
  537.     void Setchar(int input1, char input2) { *(p_mem + input1) = input2; }
  538.     void Setint(int input1, int input2) { *((int far*)p_mem + input1) = input2; }
  539.     void Setfloat(int input1, float input2)
  540.      { *((float far*)p_mem + input1) = input2; }
  541.     void Set(HWND hwnd) { SetWindowWord(hwnd, 0, hmem); }
  542.     void Get(HWND hwnd) { hmem = GetWindowWord(hwnd, 0); }
  543.     LPSTR Getp_mem() { return p_mem; }
  544. };
  545.  
  546. class LOCALARRAY_CLASS : public virtual LOCALMEMORY_CLASS{
  547.   protected:
  548.     int dim1, dim2;
  549.   public:
  550.     LOCALARRAY_CLASS() { dim1 = dim2 = 0; }
  551.     int Alloc(int input1, int input2){
  552.       dim1 = input1;
  553.       dim2 = input2;
  554.       return LOCALMEMORY_CLASS::Alloc(input1 * input2);
  555.     }
  556.     int Allocchar(int input1, int input2) { return Alloc(input1, input2); }
  557.     int Allocint(int input1, int input2)
  558.      { return Alloc(input1 * sizeof(int), input2 * sizeof(int)); }
  559.     int Allocfloat(int input1, int input2)
  560.      { return Alloc(input1 * sizeof(float), input2 * sizeof(float)); }
  561.     char Getchar(int input1, int input2)
  562.      { return LOCALMEMORY_CLASS::Getchar(input1 * dim2 + input2); }
  563.     int Getint(int input1, int input2)
  564.      { return LOCALMEMORY_CLASS::Getint(input1 * dim2 + input2); }
  565.     float Getfloat(int input1, int input2)
  566.      { return LOCALMEMORY_CLASS::Getfloat(input1 * dim2 + input2); }
  567.     void Setchar(int input1, int input2, char data)
  568.      { LOCALMEMORY_CLASS::Setchar(input1 * dim2 + input2, data); }
  569.     void Setint(int input1, int input2, int data)
  570.      { LOCALMEMORY_CLASS::Setint(input1 * dim2 + input2, data); }
  571.     void Setfloat(int input1, int input2, float data)
  572.      { LOCALMEMORY_CLASS::Setfloat(input1 * dim2 + input2, data); }
  573. };
  574.  
  575. class LOCALSTRUCT_CLASS : public virtual LOCALMEMORY_CLASS{
  576.   protected:
  577.     NPSTR p_struct;
  578.     unsigned int pnt, len, lck, sze, tmp;
  579.   public:
  580.     LOCALSTRUCT_CLASS(int input){
  581.       hmem = NULL;
  582.       p_mem = NULL;
  583.       pnt = len = lck = 0;
  584.       sze = input;
  585.     }  
  586.     void LockUp(){
  587.       if(hmem){
  588.     if(lck == 0) Lock();
  589.     lck++;
  590.       }
  591.       else lck = 0;
  592.       p_struct = p_mem + pnt * sze;
  593.     }
  594.     void LockDown(){
  595.       if(hmem){
  596.         lck--;
  597.     if(lck == 0) Unlock();
  598.       }
  599.       else lck = 0;
  600.     }
  601.     void Alloc(int input){
  602.       len = input;
  603.       LOCALMEMORY_CLASS::Alloc((DWORD)len * sze);
  604.     }
  605.     void Free(){
  606.       LOCALMEMORY_CLASS::Free();
  607.       p_struct = NULL;
  608.       pnt = len = lck = 0;
  609.     }
  610.     void Add(){
  611.       tmp = lck;
  612.       pnt = len;
  613.       len++;
  614.       Unlock();
  615.       if(len > 1){
  616.     hmem = LocalReAlloc(hmem, len * sze, LHND);
  617.     LockUp();
  618.     _fmemset(p_mem + pnt * sze, 0, sze);
  619.     LockDown();
  620.       }
  621.       else hmem = LocalAlloc(LHND, sze);
  622.       if(tmp){
  623.         Lock();
  624.     if(tmp > 1) lck = tmp;
  625.       }
  626.     }
  627.     void Remove(){
  628.       len--;
  629.       if(len){
  630.         if(pnt < len){
  631.           LockUp();
  632.       _fmemmove(p_mem + pnt * sze, p_mem + len * sze, sze);
  633.           LockDown();
  634.     }
  635.     tmp = lck;
  636.         Unlock();
  637.         hmem = GlobalReAlloc(hmem, len * sze, LHND);
  638.         if(tmp){
  639.           Lock();
  640.       if(tmp > 1) lck = tmp;
  641.         }
  642.       }
  643.       else Free();
  644.     }
  645.     void Insert(int place){
  646.       Add();
  647.       if(place < pnt)
  648.        _fmemmove(p_mem + place * sze, p_mem + (place + 1) * sze, sze * (pnt - place));
  649.     }
  650.     void Insert() { Insert(pnt); }
  651.     void Delete(int place){
  652.       pnt = place;
  653.       Remove();
  654.     }
  655.     void Delete() { Remove(); }
  656.     void First(){
  657.       pnt = 0;
  658.       p_struct = p_mem;
  659.     }
  660.     void Last(){
  661.       pnt = len - 1;
  662.       p_struct = p_mem + pnt * sze;;
  663.     }
  664.     int Next(){
  665.       if(pnt < len - 1){
  666.         pnt++;
  667.     p_struct += sze;
  668.         return TRUE;
  669.       }
  670.       else return FALSE;
  671.     }
  672.     int Prev(){
  673.       if(pnt){
  674.         pnt--;
  675.     p_struct -= sze;
  676.         return TRUE;
  677.       }
  678.       else return FALSE;
  679.     }
  680.     int Getlen() { return len; }
  681.     int Getpnt() { return pnt; }
  682.     int Getsze() { return sze; }
  683.     LPSTR Getp_struct() { return p_struct; }
  684.     LPSTR Getp_struct(int index) { return p_mem + index * sze; }
  685.     void Setpnt(int index){
  686.       pnt = index;
  687.       if(p_mem) p_struct = p_mem + pnt * sze;
  688.     }
  689.     int Test() { return len > pnt; }
  690. };
  691.  
  692. class GLOBALMEMORY_CLASS{
  693.   protected:
  694.     GLOBALHANDLE hmem;
  695.     LPSTR p_mem;
  696.     DWORD num;
  697.   public:
  698.     GLOBALMEMORY_CLASS(){
  699.       hmem = NULL;
  700.       p_mem = NULL;
  701.       num = 0;
  702.     }
  703.     int Alloc(int input1, DWORD input2){
  704.       Free();
  705.       num = input2;
  706.       hmem = GlobalAlloc(input1, input2);
  707.       return hmem;
  708.     }
  709.     int Alloc(DWORD input) { return Alloc(GHND, input); }
  710.     int Allocchar(DWORD input) { return Alloc(GHND, input); }
  711.     int Allocint(DWORD input) { return Alloc(input * sizeof(int)); }
  712.     int Allocfloat(DWORD input) { return Alloc(input * sizeof(float)); }
  713.     void Lock() { if(hmem) p_mem = GlobalLock(hmem); }
  714.     void Unlock() { if(hmem) GlobalUnlock(hmem); }
  715.     void Free(){
  716.       if(hmem){
  717.     GlobalFree(hmem);
  718.     hmem = NULL;
  719.       }
  720.       p_mem = NULL;
  721.       num = 0;
  722.     }
  723.     DWORD Getlen() { return num; }
  724.     DWORD Getcharlen() { return num; }
  725.     DWORD Getlenint() { return num / sizeof(int); }
  726.     DWORD Getlenfloat() { return num / sizeof(float); }
  727.     char Getchar(DWORD input) { return *(p_mem + input); }
  728.     int Getint(DWORD input) { return *((int far*)p_mem + input); }
  729.     float Getfloat(DWORD input) { return *((float far*)p_mem + input); }
  730.     void Setchar(DWORD input1, char input2) { *(p_mem + input1) = input2; }
  731.     void Setint(DWORD input1, int input2) { *((int far*)p_mem + input1) = input2; }
  732.     void Setfloat(DWORD input1, float input2) { *((float far*)p_mem + input1) = input2; }
  733.     LPSTR Getp_mem() { return p_mem; }
  734. };
  735.  
  736. class GLOBALARRAY_CLASS : public virtual GLOBALMEMORY_CLASS{
  737.   protected:
  738.     unsigned int dim1, dim2;
  739.   public:
  740.     GLOBALARRAY_CLASS() { dim1 = dim2 = 0; }
  741.     int Alloc(int input1, int input2){
  742.       dim1 = input1;
  743.       dim2 = input2;
  744.       return GLOBALMEMORY_CLASS::Alloc(input1 * input2);
  745.     }
  746.     int Allocchar(int input1, int input2) { return Alloc(input1, input2); }
  747.     int Allocint(int input1, int input2)
  748.      { return Alloc(input1 * sizeof(int), input2 * sizeof(int)); }
  749.     int Allocfloat(int input1, int input2)
  750.      { return Alloc(input1 * sizeof(float), input2 * sizeof(float)); }
  751.     char Getchar(int input1, int input2)
  752.      { return GLOBALMEMORY_CLASS::Getchar(input1 * dim2 + input2); }
  753.     int Getint(int input1, int input2)
  754.      { return GLOBALMEMORY_CLASS::Getint(input1 * dim2 + input2); }
  755.     float Getfloat(int input1, int input2)
  756.      { return GLOBALMEMORY_CLASS::Getfloat(input1 * dim2 + input2); }
  757.     void Setchar(int input1, int input2, char data)
  758.      { GLOBALMEMORY_CLASS::Setchar(input1 * dim2 + input2, data); }
  759.     void Setint(int input1, int input2, int data)
  760.      { GLOBALMEMORY_CLASS::Setint(input1 * dim2 + input2, data); }
  761.     void Setfloat(int input1, int input2, float data)
  762.      { GLOBALMEMORY_CLASS::Setfloat(input1 * dim2 + input2, data); }
  763. };
  764.  
  765. class GLOBALSTRUCT_CLASS : public virtual GLOBALMEMORY_CLASS{
  766.   protected:
  767.     LPSTR p_struct;
  768.     unsigned int pnt, len, lck, sze, tmp;
  769.   public:
  770.     GLOBALSTRUCT_CLASS(int input){
  771.       hmem = NULL;
  772.       p_mem = NULL;
  773.       pnt = len = lck = 0;
  774.       sze = input;
  775.     }
  776.     void LockUp(){
  777.       if(hmem){
  778.     if(lck == 0) Lock();
  779.     lck++;
  780.       }
  781.       else lck = 0;
  782.       p_struct = p_mem + pnt * sze;
  783.     }
  784.     void LockDown(){
  785.       if(hmem){
  786.         lck--;
  787.     if(lck == 0) Unlock();
  788.       }
  789.       else lck = 0;
  790.     }
  791.     void Alloc(int input){
  792.       len = input;
  793.       GLOBALMEMORY_CLASS::Alloc((DWORD)len * sze);
  794.     }
  795.     void Free(){
  796.       GLOBALMEMORY_CLASS::Free();
  797.       p_struct = NULL;
  798.       pnt = len = lck = 0;
  799.     }
  800.     void Add(){
  801.       tmp = lck;
  802.       pnt = len;
  803.       len++;
  804.       Unlock();
  805.       if(len > 1){
  806.     hmem = GlobalReAlloc(hmem, len * sze, GHND);
  807.     LockUp();
  808.         _fmemset(p_mem + pnt * sze, 0, sze);
  809.     LockDown();
  810.       }
  811.       else hmem = GlobalAlloc(GHND, sze);
  812.       if(tmp){
  813.         Lock();
  814.     if(tmp > 1) lck = tmp;
  815.       }
  816.     }
  817.     void Remove(){
  818.       len--;
  819.       if(len){
  820.         if(pnt < len){
  821.           LockUp();
  822.       _fmemmove(p_mem + pnt * sze, p_mem + len * sze, sze);
  823.           LockDown();
  824.     }
  825.     tmp = lck;
  826.         Unlock();
  827.         hmem = GlobalReAlloc(hmem, len * sze, GHND);
  828.         if(tmp){
  829.           Lock();
  830.       if(tmp > 1) lck = tmp;
  831.         }
  832.       }
  833.       else Free();
  834.     }
  835.     void Insert(int place){
  836.       Add();
  837.       if(place < pnt)
  838.        _fmemmove(p_mem + place * sze, p_mem + (place + 1) * sze, sze * (pnt - place));
  839.     }
  840.     void Insert() { Insert(pnt); }
  841.     void Delete(int place){
  842.       pnt = place;
  843.       Remove();
  844.     }
  845.     void Delete() { Remove(); }
  846.     void First(){
  847.       pnt = 0;
  848.       p_struct = p_mem;
  849.     }
  850.     void Last(){
  851.       pnt = len - 1;
  852.       p_struct = p_mem + pnt * sze;;
  853.     }
  854.     int Next(){
  855.       if(pnt < len - 1){
  856.         pnt++;
  857.     p_struct += sze;
  858.         return TRUE;
  859.       }
  860.       else return FALSE;
  861.     }
  862.     int Prev(){
  863.       if(pnt){
  864.         pnt--;
  865.     p_struct -= sze;
  866.         return TRUE;
  867.       }
  868.       else return FALSE;
  869.     }
  870.     int Getlen() { return len; }
  871.     int Getpnt() { return pnt; }
  872.     int Getsze() { return sze; }
  873.     LPSTR Getp_struct() { return p_struct; }
  874.     LPSTR Getp_struct(int index) { return p_mem + index * sze; }
  875.     void Setpnt(int index){
  876.       pnt = index;
  877.       if(p_mem) p_struct = p_mem + pnt * sze;
  878.     }
  879.     int Test() { return len > pnt; }
  880. };
  881.  
  882. class DIALOGBOX_CLASS{
  883.   protected:
  884.     HANDLE hinstance;
  885.     HWND hwnd, hdlg;
  886.     FARPROC DialogBoxFN;
  887.     int value;
  888.   public:
  889.     DIALOGBOX_CLASS(HANDLE handle) {
  890.       hinstance = handle;
  891.       hdlg = hwnd = NULL;
  892.       DialogBoxFN = NULL;
  893.     }
  894.     DIALOGBOX_CLASS(HANDLE handle, HWND hinput) {
  895.       hinstance = handle;
  896.       hwnd = hinput;
  897.       hdlg = NULL;
  898.       DialogBoxFN = NULL;
  899.     }
  900.     int DialogBox(HWND hinput, FARPROC farproc, LPSTR name){
  901.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  902.       value = ::DialogBox(hinstance, name, hinput, DialogBoxFN);
  903.       FreeProcInstance(DialogBoxFN);
  904.       return value;
  905.     }
  906.     int DialogBox(FARPROC farproc, LPSTR name){
  907.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  908.       value = ::DialogBox(hinstance, name, hwnd, DialogBoxFN);
  909.       FreeProcInstance(DialogBoxFN);
  910.       return value;
  911.     }
  912.     int DialogBoxParam(HWND hinput, FARPROC farproc, LPSTR name, LPARAM lparam){
  913.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  914.       value = ::DialogBoxParam(hinstance, name, hinput, DialogBoxFN, lparam);
  915.       FreeProcInstance(DialogBoxFN);
  916.       return value;
  917.     }
  918.     int DialogBoxParam(FARPROC farproc, LPSTR name, LPARAM lparam){
  919.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  920.       value = ::DialogBoxParam(hinstance, name, hwnd, DialogBoxFN, lparam);
  921.       FreeProcInstance(DialogBoxFN);
  922.       return value;
  923.     }
  924.     int DialogBoxInt(HWND hinput, FARPROC farproc, LPSTR name, int input)
  925.      { return DialogBoxParam(hinput, farproc, name, MAKELPARAM(input, 0)); }
  926.     int DialogBoxInt(FARPROC farproc, LPSTR name, int input)
  927.      { return DialogBoxParam(hwnd, farproc, name, MAKELPARAM(input, 0)); }
  928.     int ChildDialogBox(HWND hwnd, FARPROC farproc, LPSTR name){
  929.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  930.       value = ::DialogBox(hinstance, name, GetParent(hwnd), DialogBoxFN);
  931.       SetFocus(hwnd);
  932.       FreeProcInstance(DialogBoxFN);
  933.       return value;
  934.     }
  935.     int ChildDialogBoxParam(HWND hwnd, FARPROC farproc, LPSTR name, LPARAM lparam){
  936.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  937.       value = ::DialogBoxParam(hinstance, name, GetParent(hwnd), DialogBoxFN, lparam);
  938.       SetFocus(hwnd);
  939.       FreeProcInstance(DialogBoxFN);
  940.       return value;
  941.     }
  942.     int ChildDialogBoxInt(HWND hwnd, FARPROC farproc, LPSTR name, int input)
  943.      { return ChildDialogBoxParam(hwnd, farproc, name, MAKELPARAM(input, 0)); }
  944.     HWND CreateDialog(HWND hinput, FARPROC farproc, LPSTR name){
  945.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  946.       hdlg = ::CreateDialog(hinstance, name, hinput, DialogBoxFN);
  947.       return hdlg;
  948.     }
  949.     HWND CreateDialog(FARPROC farproc, LPSTR name){
  950.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  951.       hdlg = ::CreateDialog(hinstance, name, hwnd, DialogBoxFN);
  952.       return hdlg;
  953.     }
  954.     HWND CreateDialogParam(HWND hinput, FARPROC farproc, LPSTR name, LPARAM lparam){
  955.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  956.       hdlg = ::CreateDialogParam(hinstance, name, hinput, DialogBoxFN, lparam);
  957.       return hdlg;
  958.     }
  959.     HWND CreateDialogParam(FARPROC farproc, LPSTR name, LPARAM lparam){
  960.       DialogBoxFN = MakeProcInstance(farproc, hinstance);
  961.       hdlg = ::CreateDialogParam(hinstance, name, hwnd, DialogBoxFN, lparam);
  962.       return hdlg;
  963.     }
  964.     HWND CreateDialogInt(HWND hinput, FARPROC farproc, LPSTR name, int input)
  965.      { return CreateDialogParam(hinput, farproc, name, MAKELPARAM(input, 0)); }
  966.     HWND CreateDialogInt(FARPROC farproc, LPSTR name, int input)
  967.      { return CreateDialogParam(hwnd, farproc, name, MAKELPARAM(input, 0)); }
  968.     void Free() { if(DialogBoxFN) FreeProcInstance(DialogBoxFN); }
  969.     void Destroy(){
  970.       if(hdlg){
  971.     DestroyWindow(hdlg);
  972.     hdlg = NULL;
  973.       }
  974.       Free();
  975.     }
  976. };
  977.  
  978. class FILE_CLASS{
  979.   protected:
  980.     OFSTRUCT of;
  981.     HANDLE hfile;
  982.     BYTE eof;
  983.     union{
  984.       char b;
  985.       int i;
  986.       float f;
  987.     };
  988.     void read(LPSTR input1, int input2)
  989.      { eof = _lread(hfile, input1, input2) - input2; }
  990.   public:
  991.     FILE_CLASS() { hfile = NULL; }
  992.     ~FILE_CLASS() { if(hfile) _lclose(hfile); };
  993.     BYTE* GetszPathName() { return of.szPathName; }
  994.     int GetEOF() { return eof; }
  995.     int Open(LPSTR input1, int input2)
  996.      { return hfile = OpenFile(input1, &of, input2); }
  997.     int OpenRead(LPSTR input)
  998.      { return hfile = OpenFile(input, &of, OF_READ); }
  999.     int OpenWrite(LPSTR input)
  1000.      { return hfile = OpenFile(input, &of, OF_WRITE); }
  1001.     BYTE ReadBYTE(){
  1002.       read((LPSTR)&b, sizeof(b));
  1003.       return b;
  1004.     }
  1005.     char Readchar(){
  1006.       read((LPSTR)&b, sizeof(b));
  1007.       return b;
  1008.     }
  1009.     void WriteBYTE(char input) { _lwrite(hfile, (LPSTR)&input, sizeof(input)); }
  1010.     void Writechar(char input) { _lwrite(hfile, (LPSTR)&input, sizeof(input)); }
  1011.     WORD ReadWORD(){
  1012.       read((LPSTR)&i, sizeof(i));
  1013.       return i;
  1014.     }
  1015.     WORD Readint(){
  1016.       read((LPSTR)&i, sizeof(i));
  1017.       return i;
  1018.     }
  1019.     void WriteWORD(int input) { _lwrite(hfile, (LPSTR)&input, sizeof(input)); }
  1020.     void Writeint(int input) { _lwrite(hfile, (LPSTR)&input, sizeof(input)); }
  1021.     float ReadFLOAT(){
  1022.       read((LPSTR)&f, sizeof(f));
  1023.       return f;
  1024.     }
  1025.     float Readfloat(){
  1026.       read((LPSTR)&f, sizeof(f));
  1027.       return f;
  1028.     }
  1029.     void WriteFLOAT(float input) { _lwrite(hfile, (LPSTR)&input, sizeof(input)); }
  1030.     void Writefloat(float input) { _lwrite(hfile, (LPSTR)&input, sizeof(input)); }
  1031.     void ReadBuffer(LPSTR input1, int input2) { read(input1, input2); }
  1032.     void WriteBuffer(LPSTR input1, int input2)
  1033.      { _lwrite(hfile, input1, input2); }
  1034.     long Position() { return _llseek(hfile, 0L, 1); }
  1035.     void Seek(long input1, int input2) { _llseek(hfile, input1, input2); }
  1036.     void Seek(long input) { _llseek(hfile, input, 0); }
  1037.     void Close(){
  1038.       if(hfile){
  1039.     _lclose(hfile);
  1040.     hfile = NULL;
  1041.       }
  1042.     }
  1043. };
  1044.  
  1045. class TIMER_CLASS : public BASEWINDOW_CLASS{
  1046.   protected:
  1047.     int timer;
  1048.     HANDLE hinstance;
  1049.     FARPROC timerproc;
  1050.   public:
  1051.     TIMER_CLASS(HANDLE input){
  1052.       timer = 0;
  1053.       hinstance = input;
  1054.       hwnd = NULL;
  1055.       timerproc = NULL;
  1056.     }
  1057.     void Set(HWND input1, int input2, FARPROC input3){
  1058.       Kill();
  1059.       hwnd = input1;
  1060.       timerproc = MakeProcInstance(input3, hinstance);
  1061.       if(hwnd == NULL) timer = SetTimer(hwnd, NULL, input2, timerproc);
  1062.       else{
  1063.     timer = 1;
  1064.     SetTimer(hwnd, timer, input2, timerproc);
  1065.       }
  1066.     }
  1067.     void Set(HWND input1, FARPROC input2) { Set(input1, 200, input2); }
  1068.     void Set(FARPROC input) { Set(NULL, input); }
  1069.     void Setmessage(HWND input1, int input2){
  1070.       Kill();
  1071.       hwnd = input1;
  1072.       timer = 1;
  1073.       SetTimer(hwnd, timer, input2, NULL);
  1074.     }
  1075.     void Setmessage(HWND input) { Setmessage(input, 200); }
  1076.     void Kill(){
  1077.       if(timer){
  1078.     KillTimer(hwnd, timer);
  1079.     timer = 0;
  1080.       }
  1081.       if(timerproc) FreeProcInstance(timerproc);
  1082.       hwnd = NULL;
  1083.     }
  1084. };
  1085.  
  1086. class CURSOR_CLASS{
  1087.   protected:
  1088.     HCURSOR hcursor;
  1089.   public:
  1090.     CURSOR_CLASS() { hcursor = NULL; }
  1091.     HCURSOR Get() { return hcursor; }
  1092.     void Set(HCURSOR cursor) { hcursor = SetCursor(cursor); }
  1093.     void Show() { ShowCursor(TRUE); }
  1094.     void Hide() { ShowCursor(FALSE); }
  1095.     void SetARROW() { hcursor = SetCursor(LoadCursor(NULL, IDC_ARROW)); }
  1096.     void SetWAIT() { hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); }
  1097.     void SetCROSS() { hcursor = SetCursor(LoadCursor(NULL, IDC_CROSS)); }
  1098.     void SetUPARROW()
  1099.      { hcursor = SetCursor(LoadCursor(NULL, IDC_UPARROW)); }
  1100.     void SetSIZENWSE()
  1101.      { hcursor = SetCursor(LoadCursor(NULL, IDC_SIZENWSE)); }
  1102.     void Restore() { hcursor = SetCursor(hcursor); }
  1103.     void Destroy(){
  1104.       Set(hcursor);
  1105.       DestroyCursor(hcursor);
  1106.       hcursor = NULL;
  1107.     }
  1108. };
  1109.  
  1110. class MOUSE_CLASS{
  1111.   protected:
  1112.     HWND hwnd;
  1113.     POINT point;
  1114.   public:
  1115.     MOUSE_CLASS(HWND input) { hwnd = input; }
  1116.     void GetClientPos(){
  1117.       GetCursorPos(&point);
  1118.       ScreenToClient(hwnd, &point);
  1119.     }
  1120.     int Getx() { return point.x; }
  1121.     int Gety() { return point.y; }
  1122. };
  1123.  
  1124. class MENU_CLASS{
  1125.   protected:
  1126.     HMENU hmenu;
  1127.     HWND hwnd;
  1128.   public:
  1129.     MENU_CLASS(HWND input) { hwnd = input; }
  1130.     MENU_CLASS(HANDLE hinstance, HWND input1, LPSTR input2){
  1131.       hwnd = input1;
  1132.       hmenu = LoadMenu(hinstance, input2);
  1133.     }
  1134.     void Get() { hmenu = GetMenu(hwnd); }
  1135.     void Set() { SetMenu(hwnd, hmenu); }
  1136.     int GetState(int input1, int input2)
  1137.      { return GetMenuState(hmenu, input1, input2); }
  1138.     int GetState(int input)
  1139.      { return GetState(input, MF_BYCOMMAND); }
  1140.     void CheckItem(int input1, int input2)
  1141.      { CheckMenuItem(hmenu, input1, input2); }
  1142.     void EnableItem(int input1, int input2)
  1143.      { EnableMenuItem(hmenu, input1, input2); }
  1144. };
  1145.  
  1146. class HELP_CLASS{
  1147.   protected:
  1148.     HWND hwnd;
  1149.     char far *helpfile;
  1150.   public:
  1151.     HELP_CLASS(HWND input1, char far *input2){
  1152.       hwnd = input1;
  1153.       helpfile = input2;
  1154.     }
  1155.     void HelpIndex() { WinHelp(hwnd, helpfile, HELP_CONTENTS, 0l); }
  1156.     void Help(int input) { WinHelp(hwnd, helpfile, HELP_CONTEXT, input); }
  1157. };
  1158.  
  1159. class BASEDC_CLASS{
  1160.   protected:
  1161.     HDC hdc;
  1162.   public:
  1163.     BASEDC_CLASS() { hdc = NULL; }
  1164.     HDC GetHDC() { return hdc; }
  1165.     void SetHDC(HDC input) { hdc = input; }
  1166.     void Delete(){
  1167.       DeleteDC(hdc);
  1168.       hdc = NULL;
  1169.     }
  1170.     void Compatible(HDC input) { hdc = CreateCompatibleDC(input); }
  1171.     HANDLE Select(HANDLE handle) { return SelectObject(hdc, handle); }
  1172.     void SetPixel(int x, int y, COLORREF color)
  1173.      { ::SetPixel(hdc, x, y, color); }
  1174.     void MoveTo(int x, int y) { ::MoveTo(hdc, x, y); }
  1175.     void LineTo(int x, int y) { ::LineTo(hdc, x, y); }
  1176.     void HorizontallineTo(int x1, int x2, int y){
  1177.       MoveTo(x1, y);
  1178.       LineTo(x2, y);
  1179.     }
  1180.     void Horizontalline(int x1, int x2, int y){
  1181.       MoveTo(x1, y);
  1182.       LineTo(x2 + wdir(x1, x2), y);
  1183.     }
  1184.     void VerticallineTo(int y1, int y2, int x){
  1185.       MoveTo(x, y1);
  1186.       LineTo(x, y2);
  1187.     }
  1188.     void Verticalline(int y1, int y2, int x){
  1189.       MoveTo(x, y1);
  1190.       LineTo(x, y2 + wdir(y1, y2));
  1191.     }
  1192.     void LineTo(int x1, int y1, int x2, int y2){
  1193.       MoveTo(x1, y1);
  1194.       LineTo(x2, y2);
  1195.     }
  1196.     void Line(int x1, int y1, int x2, int y2){
  1197.       if(y1 == y2) Horizontalline(x1, x2, y1);
  1198.       else if(x1 == x2) Verticalline(y1, y2, x1);
  1199.       else{
  1200.         MoveTo(x1, y1);
  1201.         if(wabs(y1 - y2) == wabs(x1 - x2))
  1202.          LineTo(x2 + wdir(x1, x2), y2 + wdir(y1, y2));
  1203.         else if(wabs(y1 - y2) > wabs(x1 - x2))
  1204.          LineTo(x2, y2 + wdir(y1, y2));
  1205.         else
  1206.      LineTo(x2 + wdir(x1, x2), y2);
  1207.       }
  1208.     }
  1209.     void Rectangle(int right, int top, int left, int bottom)
  1210.      { ::Rectangle(hdc, right, top, left, bottom); }
  1211.     void Rectangle(RECT *rect)
  1212.      { Rectangle(rect->right, rect->top, rect->left, rect->bottom); }
  1213.     void DrawIcon(int x, int y, HICON hicon)
  1214.      { ::DrawIcon(hdc, x, y, hicon); }
  1215.     void SetTextColor(COLORREF color) { ::SetTextColor(hdc, color); }
  1216.     void SetTextColor(int r, int g, int b)
  1217.      { BASEDC_CLASS::SetTextColor(RGB(r, g, b)); }
  1218.     void SetBkColor(COLORREF color) { ::SetBkColor(hdc, color); }
  1219.     void SetBkColor(int r, int g, int b)
  1220.      { BASEDC_CLASS::SetBkColor(RGB(r, g, b)); }
  1221.     void SetBkMode(int mode) { ::SetBkColor(hdc, mode); }
  1222.     void SetBkTRANSPARENT() { BASEDC_CLASS::SetBkMode(TRANSPARENT); }
  1223.     void SetBkOPAQUE() { BASEDC_CLASS::SetBkMode(OPAQUE); }
  1224.     void TextOut(int x, int y, LPCSTR string)
  1225.      { ::TextOut(hdc, x, y, string, lstrlen(string)); }
  1226.     void DPtoLP(POINT FAR *input1, int input2)
  1227.      { ::DPtoLP(hdc, input1, input2); }
  1228. };
  1229.  
  1230. class DC_CLASS : public BASEDC_CLASS{
  1231.   protected:
  1232.     HWND hwnd;
  1233.     COLORREF rgb;
  1234.   public:
  1235.     DC_CLASS() : BASEDC_CLASS() { hwnd = NULL; }
  1236.     DC_CLASS(HWND input) : BASEDC_CLASS() { hwnd = input; }
  1237.     ~DC_CLASS(){ if(hdc) Release(); }
  1238.     void Get() { hdc = GetDC(hwnd); }
  1239.     void Get(HWND input){
  1240.       hwnd = input;
  1241.       Get();
  1242.     }
  1243.     void Release(){
  1244.       if(hdc){
  1245.         if(hwnd) ReleaseDC(hwnd, hdc);
  1246.     hdc = NULL;
  1247.       }
  1248.     }
  1249.     void SetRGB(COLORREF color) { rgb = color; }
  1250.     void SetRGB(int r, int g, int b) { rgb = RGB(r, g, b); }
  1251.     void SetPixelRGB(int x, int y) { BASEDC_CLASS::SetPixel(x, y, rgb); }
  1252.     void SetTextColorRGB() { BASEDC_CLASS::SetTextColor(rgb); }
  1253.     void SetBkColorRGB() { BASEDC_CLASS::SetBkColor(rgb); }
  1254. };
  1255.  
  1256. class PAINT_CLASS : public DC_CLASS{
  1257.   protected:
  1258.     PAINTSTRUCT ps;
  1259.   public:
  1260.     PAINT_CLASS() : DC_CLASS() { }
  1261.     PAINT_CLASS(HWND input) : DC_CLASS(input) { }
  1262.     ~PAINT_CLASS() { if(hwnd) EndPaint(hwnd, &ps); }
  1263.     void Begin() { if(hwnd) hdc = BeginPaint(hwnd, &ps); }
  1264.     void Begin(HWND input){
  1265.       hwnd = input;
  1266.       Begin();
  1267.     }
  1268.     void End(){
  1269.       if(hwnd){
  1270.     EndPaint(hwnd, &ps);
  1271.     hwnd = NULL;
  1272.     hdc = NULL;
  1273.       }
  1274.     }
  1275.     int Getleft() { return ps.rcPaint.left; }
  1276.     int Getright() { return ps.rcPaint.right; }
  1277.     int Gettop() { return ps.rcPaint.top; }
  1278.     int Getbottom() { return ps.rcPaint.bottom; }
  1279.     RECT *Getrect() { return &ps.rcPaint; }
  1280.     void Rectangle() { DC_CLASS::Rectangle(&ps.rcPaint); }
  1281.     void Rectangle(int right, int top, int left, int bottom)
  1282.      { DC_CLASS::Rectangle(right, top, left, bottom); }
  1283.     void Rectangle(RECT *rect) { DC_CLASS::Rectangle(rect); }
  1284. };
  1285.  
  1286. class TEXT_CLASS : public virtual DC_CLASS{
  1287.   protected:
  1288.     TEXTMETRIC tm;
  1289.   public:
  1290.     TEXT_CLASS() : DC_CLASS() { }
  1291.     TEXT_CLASS(HWND hwnd) : DC_CLASS(hwnd) { Get(); }
  1292.     void Get(HDC input){
  1293.       if(hdc) Release();
  1294.       hdc = input; 
  1295.       if(hdc) GetTextMetrics(hdc, &tm);
  1296.     }
  1297.     void Get(){
  1298.       if(hdc == NULL) DC_CLASS::Get();
  1299.       if(hdc) GetTextMetrics(hdc, &tm);
  1300.       Release();
  1301.     }
  1302.     int GetHeight() { return tm.tmHeight; }
  1303.     int GetAscent() { return tm.tmAscent; }
  1304.     int GetDescent() { return tm.tmDescent; }
  1305.     int GetInternalLeading() { return tm.tmInternalLeading; }
  1306.     int GetExternalLeading() { return tm.tmExternalLeading; }
  1307.     int GetAveCharWidth() { return tm.tmAveCharWidth; }
  1308.     int GetMaxCharWidth() { return tm.tmMaxCharWidth; }
  1309.     int GetWeight() { return tm.tmWeight; }
  1310.     int GetOverhang() { return tm.tmOverhang; }
  1311.     int GetDigitizedAspectX() { return tm.tmDigitizedAspectX; }
  1312.     int GetDigitizedAspectY() { return tm.tmDigitizedAspectY; }
  1313. };
  1314.  
  1315. class BRUSH_CLASS : public virtual PAINT_CLASS{
  1316.   protected:
  1317.     HBRUSH hbrush;
  1318.   public:
  1319.     BRUSH_CLASS() : PAINT_CLASS() { hbrush = NULL; }
  1320.     BRUSH_CLASS(HWND input) : PAINT_CLASS(input) { hbrush = NULL; }
  1321.     virtual void CreateSolid(COLORREF input)
  1322.      { hbrush = CreateSolidBrush(input); }
  1323.     virtual void CreateSolid(int r, int g, int b) { CreateSolid(RGB(r, g, b)); }
  1324.     void CreateSolid() { hbrush = CreateSolidBrush(rgb); }
  1325.     void GetStock(int input) { hbrush = GetStockObject(input); }
  1326.     HANDLE Select() { return hbrush = DC_CLASS::Select(hbrush); }
  1327.     void Delete(){
  1328.       if(hbrush){
  1329.     DeleteObject(hbrush);
  1330.         hbrush = NULL;
  1331.       }
  1332.     }
  1333.     void SelectDelete(){
  1334.       Select();
  1335.       Delete();
  1336.     }
  1337.     virtual void SelectSolid(int r, int g, int b){
  1338.       CreateSolid(r, g, b);
  1339.       Select();
  1340.     }
  1341.     virtual void SelectSolid(COLORREF input){
  1342.       CreateSolid(input);
  1343.       Select();
  1344.     }
  1345.     void SelectSolid(){
  1346.       CreateSolid();
  1347.       Select();
  1348.     }
  1349.     void FrameRect(RECT *rect) { ::FrameRect(hdc, rect, hbrush); }
  1350. };
  1351.  
  1352. class PEN_CLASS : public virtual PAINT_CLASS{
  1353.   protected:
  1354.     HPEN hpen;
  1355.   public:
  1356.     PEN_CLASS() : PAINT_CLASS() { hpen = NULL; }
  1357.     PEN_CLASS(HWND hwnd) : PAINT_CLASS(hwnd) { hpen = NULL; }
  1358.     void CreatePen(int style, int width, COLORREF color)
  1359.      { hpen = ::CreatePen(style, width, color); }
  1360.     void CreateSolid(int width, COLORREF color)
  1361.      { CreatePen(PS_SOLID, width, color); }
  1362.     virtual void CreateSolid(COLORREF color)
  1363.      { CreateSolid(0, color); }
  1364.     virtual void CreateSolid(int r, int g, int b) { CreateSolid(RGB(r, g, b)); }
  1365.     void CreateDot(int width, COLORREF color){
  1366.       if(width > 0) CreatePen(PS_DOT, width, color);
  1367.       else CreatePen(PS_DOT, 1, color);
  1368.     }
  1369.     void CreateDot(COLORREF color) { CreateDot(1, color); }
  1370.     void GetStock(int input) { hpen = GetStockObject(input); }
  1371.     HANDLE Select() { return hpen = DC_CLASS::Select(hpen); }
  1372.     void Delete(){
  1373.       if(hpen){
  1374.     DeleteObject(hpen);
  1375.         hpen = NULL;
  1376.       }
  1377.     }
  1378.     void SelectDelete(){
  1379.       Select();
  1380.       Delete();
  1381.     }
  1382.     void SelectPen(int style, int width, COLORREF color){
  1383.       CreatePen(style, width, color);
  1384.       Select();
  1385.     }
  1386.     void SelectPen(int style, int width){
  1387.       CreatePen(style, width, rgb);
  1388.       Select();
  1389.     }
  1390.     void SelectSolid(int width, COLORREF color)
  1391.      { SelectPen(PS_SOLID, width, color); }
  1392.     void SelectSolid(COLORREF color) { SelectSolid(0, color); }
  1393.     void SelectSolid(int r, int g, int b) { SelectSolid(RGB(r, g, b)); }
  1394.     void SelectSolid() { SelectSolid(rgb); }
  1395.     void SelectDot(int width, COLORREF color)
  1396.      { SelectPen(PS_DOT, width, color); }
  1397.     void SelectDot(COLORREF color) { SelectDot(1, color); }
  1398.     void SelectDot(int r, int g, int b) { SelectDot(RGB(r, g, b)); }
  1399.     void SelectDot() { SelectDot(rgb); }
  1400.     void SelectStock(int input){
  1401.       GetStock(input);
  1402.       Select();
  1403.     }
  1404. };
  1405.  
  1406. class BRUSHPEN_CLASS : public virtual PAINT_CLASS, public virtual BRUSH_CLASS,
  1407.  public virtual PEN_CLASS{
  1408.   public:
  1409.     BRUSHPEN_CLASS() : BRUSH_CLASS() , PEN_CLASS() { }
  1410.     BRUSHPEN_CLASS(HWND input) : PAINT_CLASS(input), BRUSH_CLASS(input) , PEN_CLASS(input) { }
  1411.     void CreateSolid(COLORREF input){
  1412.       BRUSH_CLASS::CreateSolid(input);
  1413.       PEN_CLASS::CreateSolid(input);
  1414.     }
  1415.     void CreateSolid(COLORREF brush, COLORREF pen){
  1416.       BRUSH_CLASS::CreateSolid(brush);
  1417.       PEN_CLASS::CreateSolid(pen);
  1418.     }
  1419.     void CreateSolid(int r, int g, int b) { CreateSolid(RGB(r, g, b)); }
  1420.     void Select(){
  1421.       BRUSH_CLASS::Select();
  1422.       PEN_CLASS::Select();
  1423.     }
  1424.     void Delete(){
  1425.       BRUSH_CLASS::Delete();
  1426.       PEN_CLASS::Delete();
  1427.     }
  1428.     void SelectDelete(){
  1429.       Select();
  1430.       Delete();
  1431.     }
  1432.     void SelectSolid(COLORREF input){
  1433.       CreateSolid(input);
  1434.       Select();
  1435.     }
  1436.     void SelectSolid(int r, int g, int b) { SelectSolid(RGB(r, g, b)); }
  1437.     void SelectSolid() { SelectSolid(rgb); }
  1438.     void SelectSolid(COLORREF brush, COLORREF pen){
  1439.       CreateSolid(brush, pen);
  1440.       Select();
  1441.     }
  1442. };
  1443.  
  1444. class BITMAP_CLASS : public PAINT_CLASS{
  1445.   protected:
  1446.     HBITMAP hbm;
  1447.     BITMAP bm;
  1448.     HDC hdcmem;
  1449.     unsigned char flag;
  1450.   public:
  1451.     BITMAP_CLASS() : PAINT_CLASS(){
  1452.       hbm = NULL;
  1453.       hdcmem = NULL;
  1454.       flag = FALSE;
  1455.     }
  1456.     BITMAP_CLASS(HWND input) : PAINT_CLASS(input){
  1457.       hbm = NULL;
  1458.       hdcmem = NULL;
  1459.       flag = FALSE;
  1460.     }
  1461.     ~BITMAP_CLASS() { Cleanup(); }
  1462.     HDC GetHDCMEM() { return hdcmem; }
  1463.     HBITMAP GetHBITMAP() { return hbm; }
  1464.     void Load(HANDLE input1, LPSTR input2){
  1465.       hbm = LoadBitmap(input1, input2);
  1466.       flag = TRUE;
  1467.     }
  1468.     void Setbitmap(HBITMAP input) { hbm = input; }
  1469.     void Setup(){
  1470.       if(hdcmem == NULL) hdcmem = CreateCompatibleDC(hdc);
  1471.       if(hbm){
  1472.         GetObject(hbm, sizeof(BITMAP), (LPSTR)&bm);
  1473.         hbm = ::SelectObject(hdcmem, hbm);
  1474.       }
  1475.     }
  1476.     void Setup(HBITMAP input){
  1477.       hbm = input;
  1478.       Setup();
  1479.     }
  1480.     void Setup(int dx, int dy, int del){
  1481.       hdcmem = CreateCompatibleDC(hdc);
  1482.       hbm = CreateCompatibleBitmap(hdc, dx, dy);
  1483.       if(hbm){
  1484.         GetObject(hbm, sizeof(BITMAP), (LPSTR)&bm);
  1485.         hbm = ::SelectObject(hdcmem, hbm);
  1486.       }
  1487.       flag = del;
  1488.     }
  1489.     void Setup(int dx, int dy) { Setup(dx, dy, TRUE); }
  1490.     void Cleanup(){
  1491.       hbm = ::SelectObject(hdcmem, hbm);
  1492.       if(hdcmem){
  1493.         DeleteDC(hdcmem);
  1494.         hdcmem = NULL;
  1495.       }
  1496.       if(hbm && flag) DeleteObject(hbm);
  1497.       hbm = NULL;
  1498.       hdc = NULL;
  1499.     }
  1500.     void Draw(int x, int y, int dx, int dy)
  1501.      { BitBlt(hdc, x, y, dx, dy, hdcmem, 0, 0, SRCCOPY); }
  1502.     virtual void Draw(int x, int y) { Draw(x, y, bm.bmWidth, bm.bmHeight); }
  1503.     virtual void Draw() { Draw(0, 0); }
  1504.     void Drawup(int x, int y, int dx, int dy){
  1505.       Setup();
  1506.       BitBlt(hdc, x, y, dx, dy, hdcmem, 0, 0, SRCCOPY);
  1507.       Cleanup();
  1508.     }
  1509.     void Draw(HBITMAP hbitmap, int x, int y, int dx, int dy){
  1510.       hbm = ::SelectObject(hdcmem, hbitmap);
  1511.       BitBlt(hdc, x, y, dx, dy, hdcmem, 0, 0, SRCCOPY);
  1512.     }
  1513.     void Drawpartial(int x, int y, int dx, int dy)
  1514.      { BitBlt(hdc, 0, 0, dx, dy, hdcmem, x, y, SRCCOPY); }
  1515.     void Drawpartial(int dstx, int dsty, int srcx, int srcy, int dx, int dy)
  1516.      { BitBlt(hdc, dstx, dsty, dx, dy, hdcmem, srcx, srcy, SRCCOPY); }
  1517.     void Stretch(int x, int y, int dx1, int dy1, int dx2, int dy2)
  1518.      { StretchBlt(hdc, x, y, dx1, dy1, hdcmem, 0, 0, dx2, dy2, SRCCOPY); }
  1519.     void Stretch(int x1, int y1, int dx1, int dy1, int x2, int y2, int dx2, int dy2)
  1520.      { StretchBlt(hdc, x1, y1, dx1, dy1, hdcmem, x2, y2, dx2, dy2, SRCCOPY); }
  1521.     void Stretch(int dx, int dy)
  1522.      { StretchBlt(hdc, 0, 0, dx, dy, hdcmem, 0, 0, bm.bmWidth, bm.bmHeight,
  1523.       SRCCOPY); }
  1524.     void Stretch(HBITMAP hbitmap, int x, int y, int dx1, int dy1, int dx2, int dy2){
  1525.       ::SelectObject(hdcmem, hbitmap);
  1526.       StretchBlt(hdc, x, y, dx1, dy1, hdcmem, 0, 0, dx2, dy2, SRCCOPY);
  1527.     }
  1528.     void StretchUp(int x, int y, int dx1, int dy1, int dx2, int dy2){
  1529.        Setup();
  1530.        StretchBlt(hdc, x, y, dx1, dy1, hdcmem, 0, 0, dx2, dy2, SRCCOPY);
  1531.        Cleanup();
  1532.     }
  1533. };
  1534.  
  1535. class BITMAPCONVERT_CLASS : public virtual BITMAP_CLASS{
  1536.   protected:
  1537.     POINT size, origin;
  1538.   public:
  1539.     BITMAPCONVERT_CLASS(HWND hwnd) : BITMAP_CLASS(hwnd) { }
  1540.     void Convert(){
  1541.       GetObject(hbm, sizeof(BITMAP), (LPSTR)&bm);
  1542.       size.x = bm.bmWidth;
  1543.       size.y = bm.bmHeight;
  1544.       DPtoLP(&size, 1);
  1545.       origin.x = 0;
  1546.       origin.y = 0;
  1547.       DPtoLP(&origin, 1);
  1548.     }
  1549.     void Setup(){
  1550.       BITMAP_CLASS::Setup();
  1551.       SetMapMode(hdcmem, GetMapMode(hdc));
  1552.       Convert();
  1553.     }
  1554.     void Setup(HBITMAP input){
  1555.       hbm = input;
  1556.       BITMAPCONVERT_CLASS::Setup();
  1557.     }
  1558.     void Draw(int x, int y){
  1559.       Setup();
  1560.       BitBlt(hdc, x, y, size.x, size.y, hdcmem, origin.x, origin.y,
  1561.        SRCCOPY);
  1562.       Cleanup();
  1563.     }
  1564.     void Draw() { Draw(0, 0); }
  1565.     void Draw(HBITMAP hbitmap, int x, int y){
  1566.       ::SelectObject(hdcmem, hbitmap);
  1567.       BitBlt(hdc, x, y, size.x, size.y, hdcmem, origin.x, origin.y,
  1568.        SRCCOPY);
  1569.     }
  1570. };
  1571.  
  1572. class FONT_CLASS : public virtual DC_CLASS{
  1573.   protected:
  1574.     LOGFONT logfont;
  1575.     HFONT hfont;
  1576.   public:
  1577.     FONT_CLASS(){
  1578.       logfont.lfHeight = 0;
  1579.       logfont.lfWidth = 0;
  1580.       logfont.lfEscapement = 0;
  1581.       logfont.lfOrientation = 0;
  1582.       logfont.lfWeight = 0;
  1583.       logfont.lfItalic = FALSE;
  1584.       logfont.lfUnderline = FALSE;
  1585.       logfont.lfStrikeOut = FALSE;
  1586.       logfont.lfCharSet = 0;
  1587.       logfont.lfOutPrecision = 0;
  1588.       logfont.lfClipPrecision = 0;
  1589.       logfont.lfQuality = 0;
  1590.       logfont.lfPitchAndFamily = 0;
  1591.       logfont.lfFaceName[0] = NULL;
  1592.       hfont = NULL;
  1593.     }
  1594.     void Create() { hfont = CreateFontIndirect(&logfont); }
  1595.     void Select() { if(hfont) DC_CLASS::Select(hfont); }
  1596.     void Delete(){
  1597.       DeleteObject(hfont);
  1598.       hfont = NULL;
  1599.     }
  1600. };
  1601.  
  1602. class PRINT_CLASS : public BASEDC_CLASS{
  1603.   protected:
  1604.     int error;
  1605.     RECT band;
  1606.   public:
  1607.     PRINT_CLASS(){
  1608.       error = FALSE;
  1609.       SetRectEmpty(&band);
  1610.     } 
  1611.     void Startdoc(LPSTR string){
  1612.       string[wmin(lstrlen(string), 31)] = 0;
  1613.       error = Escape(hdc, STARTDOC, lstrlen(string), string, NULL);
  1614.       if(error > 0) error = 0;
  1615.       else if(error == 0) error = SP_ERROR;
  1616.     }
  1617.     void Newframe(){
  1618.       error = Escape(hdc, NEWFRAME, NULL, NULL, NULL);
  1619.       if(error > 0) error = 0;
  1620.       else if(error == 0) error = SP_ERROR;
  1621.     }
  1622.     int Nextband(){
  1623.       error = Escape(hdc, NEXTBAND, NULL, NULL, &band);
  1624.       if(error > 0) error = 0;
  1625.       else if(error == 0) error = SP_ERROR;
  1626.       return error == FALSE && IsRectEmpty(&band) == FALSE;
  1627.     }
  1628.     void Enddoc(){
  1629.       error = Escape(hdc, ENDDOC, NULL, NULL, NULL);
  1630.       if(error > 0) error = 0;
  1631.       else if(error == 0) error = SP_ERROR;
  1632.     }
  1633.     void Setabortproc(FARPROC abortproc){
  1634.       error = Escape(hdc, SETABORTPROC, 0, (LPSTR)abortproc, NULL);
  1635.       if(error > 0) error = 0;
  1636.       else if(error == 0) error = SP_ERROR;
  1637.     }
  1638.     int Geterror() { return error; }
  1639.     int Getleft() { return band.left; }
  1640.     int Gettop() { return band.top; }
  1641.     int Getright() { return band.right; }
  1642.     int Getbottom() { return band.bottom; }
  1643.     void Seterror(int input) { error = input; }
  1644.     void Seterror() { error = TRUE; }
  1645.     void Reseterror() { error = FALSE; }
  1646.     void Copyband(RECT *rect) { CopyRect(rect, &band); }
  1647.     int Testband() { return IsRectEmpty(&band) == FALSE; }
  1648. };
  1649.  
  1650. #endif